#include "transferwidget.h"
#include "modelview/utransferwidget.h"

#include <QHBoxLayout>
#include <QStandardItemModel>
#include <QDateTime>

TransferWidget::TransferWidget(QWidget* parent) : UWidget(parent)
{
    setBackgroundRole(QPalette::Base);
    setRadius(8);

    UTransferWidget* view = new UTransferWidget(this);
    QStandardItemModel* leftModel = view->leftModel();
    QStandardItemModel* rightModel = view->rightModel();
    QStringList list = {"checkbox", tr("Name"), tr("Date")};
    leftModel->setHorizontalHeaderLabels(list);
    rightModel->setHorizontalHeaderLabels(list);
    QDateTime time = QDateTime::currentDateTime();
    for (int var = 0; var < 6; ++var)
    {
        QStandardItem* item = new QStandardItem();
        item->setData(false, Qt::DisplayRole);
        QStandardItem* item1 = new QStandardItem(QString("Left_Item_%1").arg(var + 1));
        time = time.addSecs(60);
        QStandardItem* item2 = new QStandardItem(time.toString());
        QList<QStandardItem*> list = {item, item1, item2};
        leftModel->appendRow(list);

        QStandardItem* rightItem = new QStandardItem();
        rightItem->setData(false, Qt::DisplayRole);
        QStandardItem* rightItem1 = new QStandardItem(QString("Right_Item_%1").arg(var + 1));
        time = time.addSecs(60);
        QStandardItem* rightItem2 = new QStandardItem(time.toString());
        QList<QStandardItem*> rightList = {rightItem, rightItem1, rightItem2};
        rightModel->appendRow(rightList);
    }

    QList<int> widths = {40, 100, 160};
    view->setLeftColumnWidth(widths);
    view->setRightColumnWidth(widths);

    QVBoxLayout* mainLayout = new QVBoxLayout;
    mainLayout->addWidget(view);
    setLayout(mainLayout);
}

TransferWidget::~TransferWidget()
{
}
